import "./css/normalize.css";
import "./sass/index.scss";
import "./css/idangerous.swiper.css";
import "./css/animate.min.css";
import "./css/video-js.min.css";

window.onload = () => {
    console.log($);
    let mySwiper = new Swiper('.swiper-container',{
        pagination: '.pagination',
        grabCursor: true,
        paginationClickable: true,
        autoplay:5000,
        onSlideChangeEnd: function(swiper){
            console.log(swiper.activeIndex)
            if(swiper.activeIndex == 0){
                $("#phone").siblings().removeClass("active");
                $("#phone").addClass("active");
            }
            if(swiper.activeIndex == 1){
                $("#pc").siblings().removeClass("active");
                $("#pc").addClass("active");
            }
            if(swiper.activeIndex == 2){
                $("#client").siblings().removeClass("active");
                $("#client").addClass("active");
            }
        }
    })
    let descSwiper = new Swiper('.desc-swiper',{
        pagination: '.pagination-desc',
        grabCursor: true,
        paginationClickable: true,
        autoplay:2000
    })
    $('.swiper-slide').mouseenter(function() {
        mySwiper.stopAutoplay();
        descSwiper.stopAutoplay();
    })
    // 鼠标移出开始自动滚动
    $('.swiper-slide').mouseleave(function() {
        mySwiper.startAutoplay();
        descSwiper.startAutoplay();
    })
    $('#phone').click(function(){
        mySwiper.swipeTo(0, 1000, false);
        $(this).siblings().removeClass("active");
        $(this).addClass("active");
    });
    $('#pc').click(function(){
        mySwiper.swipeTo(1, 1000, false);
        $(this).siblings().removeClass("active");
        $(this).addClass("active");
    });
    $('#client').click(function(){
        mySwiper.swipeTo(2, 1000, false);
        $(this).siblings().removeClass("active");
        $(this).addClass("active");
    });



    // 动效
    var clientHeight = $(window).height();
    console.log(clientHeight)
    $('.desc').addClass('animated fadeInDownBig');
    // 第二张页面
    console.log($(document).scroll);
    $("body").scroll(function(){
        var scroH = $(this).scrollTop();  //滚动高度
        console.log(scroH)
        if(scroH>3500){
            $('.page-six .left-png').addClass('animated bounceInLeft');
            $('.page-six .right-info-cont').addClass('animated bounceInRight');
        }
    });
    // 
    var player = videojs('my-video', {}, function onPlayerReady() {
    });
    $(".play").on("click",function(){
        $(".video-wrap").removeClass("hidden").addClass("show");
        player.play();
    });
    $(".video-wrap").on("click",function(){
        $(".video-wrap").removeClass("show").addClass("hidden");
        player.pause();
        // player.currentTime(0);
    });
    $("#my-video").on("click",function(e){
        e.stopPropagation();
    });
    // page five
    $(".page-five li").on("mouseenter",function(){
        $(this).siblings().removeClass("active");
        $(this).addClass("active");
    })
};